package com.zhangpf.boot.entity;

import java.io.Serializable;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel(value = "ResultVO", description = "接口返回值封装VO")
public class ResultVO<T> implements Serializable {

	private static final long serialVersionUID = 1L;

	@ApiModelProperty(value = "返回编码，200表示成功")
	private String code;

	@ApiModelProperty(value = "提示信息")
    private String message;

	@ApiModelProperty(value = "返回数据")
    private T data;

    public ResultVO() {
        this.setCode("200");
    }

    public ResultVO(T data) {
        this.setCode("200");
        this.setMessage("success");;
        this.data=data;
    }

    public ResultVO(String code, String msg) {
        this.code = code;
        this.message = msg;
    }

    public ResultVO(String code, String msg, T data) {
        this.code = code;
        this.message = msg;
        this.data = data;
    }

    /***
     * <p>Description: 接口返回值封装VO 修改为泛型方式</p>
     * @return com.sunjinke.fundcore.entity.ResultVO<T>
     * @author zhangjunping
     * @date 2019/5/5 17:11
     */
    public static <T> ResultVO<T> success(){
        return new ResultVO<>();
    }

    public static <T> ResultVO<T> success(T t){
        return new ResultVO<>(t);
    }

    public static<T>  ResultVO<T>  error() {
        return error("500", "未知异常，请联系管理员");
    }

    public static<T>  ResultVO<T>  error(String msg) {
        return error("500", msg);
    }

    public static<T> ResultVO<T> error(String code, String msg) {
        ResultVO<T> result = new ResultVO<T>();
        result.setCode(code);
        result.setMessage(msg);
        return result;
    }

    public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}


	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	@Override
	public String toString() {
		return "ResultVO [code=" + code + ", message=" + message + ", data=" + data + "]";
	}

	
	

}
